package com.eonmind.pay.task;

import com.eonmind.pay.mapper.CartMapper;
import com.eonmind.pay.mapper.OrderMapper;
import com.eonmind.pay.service.CartService;
import com.eonmind.pay.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName AsyncTasks
 * @Description TODO
 * Author 32004
 * Date 2025/5/31 19:45
 * Version 1.0
 **/

@Component
public class AsyncTasks {

    @Resource
    CartMapper cartMapper;

    @Async("asyncExecutor")
    public void processUserCart(List<Long> cartIds,Long orderId,Long userId){
        cartIds.forEach(id->{
            cartMapper.updateOrderId(id,orderId);
        });
    }

    @Async("asyncExecutor")
    public void removeCarts(List<Long> productIds,Long userId){
        productIds.forEach(id->{
            cartMapper.removeCart(userId,id);
        });
    }

}
